<template>
  <div class="container">
    <router-view />
    <div class="bottom-nav">
      <div class="nav-item active" data-tab="/home">
        <i class="fas fa-home"></i>
        <span>首页</span>
      </div>
      <div class="nav-item" data-tab="/analysis">
        <i class="fas fa-chart-line"></i>
        <span>分析</span>
      </div>
      <div class="nav-item" data-tab="/profile">
        <i class="fas fa-user"></i>
        <span>我的</span>
      </div>
    </div>
  </div>
</template>

<script>

export default {
  name: 'App',
  components: {
  },
  data() {
    return {
      tabName: 'efficiency'
    }
  },
  mounted () {
    const tabs = document.querySelectorAll('.tab');
    tabs.forEach(tab => {
      tab.addEventListener('click', () => {
        this.tabName = tab.getAttribute('data-tab');
        console.log('tabName', this.tabName);
      });
    });
    const navItems = document.querySelectorAll('.nav-item');
    navItems.forEach(navItem => {
      navItem.addEventListener('click', () => {
        navItems.forEach(t => t.classList.remove('active'));
        navItem.classList.add('active');
        let path = navItem.getAttribute('data-tab');
        console.log(this.tabName);
        if (path === this.tabName) {
          return
        }
        console.log('navItem', path);
        this.$router.replace(path)
      })
    })
  }
}
</script>

<style>
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
}

:root {
  --primary: #4361ee;
  --secondary: #3f37c9;
  --accent: #4cc9f0;
  --success: #4caf50;
  --warning: #ff9800;
  --danger: #f44336;
  --dark: #121212;
  --light: #f8f9fa;
  --card-bg: rgba(30, 30, 46, 0.8);
  --text-primary: #e0e0e0;
  --text-secondary: #b0b0b0;
  --transition: all 0.3s ease;
}

body {
  color: var(--text-primary);
  min-height: 100vh;
  padding: 0;
  display: flex;
  justify-content: center;
  align-items: center;
}

.container {
  max-width: 500px;
  background: whitesmoke;
  backdrop-filter: blur(10px);
  overflow: auto;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.section-title {
  font-size: 1.4rem;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.section-title i {
  color: var(--accent);
  font-size: 1.3rem;
}

.efficiency-item h3 {
  color: var(--text-primary);
  font-size: 1.1rem;
  margin-bottom: 5px;
}

.efficiency-item p {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.workout-type i {
  font-size: 1.8rem;
  color: var(--accent);
  margin-bottom: 10px;
}

.workout-type span {
  color: var(--text-primary);
  font-size: 0.9rem;
}

@keyframes moveLine {
  0% { transform: translateX(0); }
  100% { transform: translateX(-40px); }
}

/* 底部导航 */
.bottom-nav {
  position: fixed;  /* 固定定位 */
  bottom: 0;       /* 定位在底部 */
  left: 0;         /* 从左侧开始 */
  right: 0;        /* 到右侧结束（铺满宽度） */
  //box-shadow: 0 -5px 25px rgba(0, 0, 0, 0.1);
  height: 100px;    /* 导航栏高度 */
  display: flex;   /* 使用Flex布局排列导航项 */
  z-index: 1000;   /* 确保导航栏在最上层 */
  justify-content: space-around;
  padding: 15px;
  background: whitesmoke;
  border-top: 1px solid rgba(76, 201, 240, 0.1);
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  color: var(--text-secondary);
  font-size: 0.8rem;
  cursor: pointer;
  transition: var(--transition);
  padding: 5px 15px;
  //border-radius: 15px;
}

.nav-item.active {
  color: var(--accent);
  //background: rgba(20, 185, 236, 0.1);
}

.nav-item i {
  font-size: 1.4rem;
  margin-bottom: 5px;
}

/* 响应式设计 */
@media (max-width: 400px) {
  .efficiency-grid {
    grid-template-columns: 1fr;
  }

  .fitness-stats {
    grid-template-columns: 1fr;
  }

  .workout-types {
    grid-template-columns: repeat(2, 1fr);
  }
}

</style>
